<script setup lang="ts">
import BaseEchart from '@/base-ui/echarts/BaseEchart.vue'
import type { IPieEchartData } from '../types'

const props = defineProps<{ pieData: IPieEchartData[] }>()

// 用计算属性来 万一里面的props的属性发生了变化 可以获得最新的数据
const options: any = computed(() => {
  return {
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'horizontal', // 横向排列
      left: 'left'
    },
    series: [
      {
        name: '数据源',
        type: 'pie',
        radius: '50%',
        data: props.pieData,
        emphasis: {
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: 'rgba(0, 0, 0, 0.5)'
          }
        }
      }
    ]
  }
})
</script>

<template>
  <div class="pei-echart">
    <BaseEchart :options="options"></BaseEchart>
  </div>
</template>

<style scoped></style>
